import { service } from "../http/request";

/**
 * 获取所有角色
 */
const getRoles = () => {
  return service({
    method:'get',
    url:'system/basic/permission/',
  })
}

/**
 * 获取所有菜单
 */
const getMenuData = () => {
  return service({
    method:'get',
    url:'system/basic/permission/menus',
  })
}

/**
 * 根据角色id获取id
 */
const getMenuByRid = (rid) => {
  return service({
    method: 'get',
    url: '/system/basic/permission/mid/' + rid,
  })
}

/**
 * 根据角色id更新菜单id
 */
const updateMenuRole = (rid,mids) => {
  return service({
    method: 'put',
    url: '/system/basic/permission/',
    data: {rid,mids}
  })
}

/**
 * 添加角色
 */
const addRole = (params) => {
  return service({
    method: 'post',
    url: '/system/basic/permission/role',
    data: params
  })
}

/**
 * 删除角色
 */
const deleteRole = (rid) => {
  return service({
    method: 'delete',
    url:'/system/basic/permission/role/' + rid
  })
}


export default {
  getRoles,
  getMenuData,
  getMenuByRid,
  updateMenuRole,
  addRole,
  deleteRole
}
